<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('提现管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>kkid：</p>
                                <input type="text" name="kkid"/>
                            </li>
                            <li>
                                <p>状态：</p>
                                <select name="status" th:with="type=${@dict.getType('yingyu_withdraw_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>openid：</p>
                                <input type="text" name="openid"/>
                            </li>
                            <li>
                                <p>审核状态：</p>
                                <select name="approve" th:with="type=${@dict.getType('yingyu_withdraw_approve_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>转帐状态：</p>
                                <select name="transfer" th:with="type=${@dict.getType('yingyu_withdraw_transfer_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>提现ip：</p>
                                <input type="text" name="ip"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('yingyu:withdraw:edit')}]];
        var removeFlag = [[${@permission.hasPermi('yingyu:withdraw:remove')}]];
        var approveFlag = [[${@permission.hasPermi('yingyu:withdraw:approve')}]];
        var transferFlag = [[${@permission.hasPermi('yingyu:withdraw:transfer')}]];
        var statusDatas = [[${@dict.getType('yingyu_withdraw_status')}]];
        var approveDatas = [[${@dict.getType('yingyu_withdraw_approve_status')}]];
        var transferDatas = [[${@dict.getType('yingyu_withdraw_transfer_status')}]];
        var prefix = ctx + "yingyu/withdraw";

        $(function() {
            var options = {
            	sortName: "createTime",
         		sortOrder: "desc",
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "提现管理",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'nickname', 
                    title : '昵称',
                    visible: true
                },
                {
                    field : 'kkid', 
                    title : 'kkid'
                },
                {
                    field : 'yuan', 
                    title : '提现金额(元)'
                },
                {
                    field : 'createTime', 
                    title : '提现时间'
                },
                {
                    field : 'status', 
                    title : '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field : 'openid', 
                    title : '微信openid',
                    visible: false
                },
                {
                    field : 'approve', 
                    title : '审核状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(approveDatas, value);
                    }
                },
                {
                    field : 'approveBy', 
                    title : '审核用户'
                },
                {
                    field : 'approveTime', 
                    title : '审核时间'
                },
                {
                    field : 'transfer', 
                    title : '转帐状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(transferDatas, value);
                    }
                },
                {
                    field : 'transferBy', 
                    title : '转帐用户'
                },
                {
                    field : 'transferTime', 
                    title : '转帐时间'
                },
                {
                    field : 'ip', 
                    title : '提现ip'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status == 1){
                        	actions.push('<a class="btn btn-success btn-xs ' + approveFlag + '" href="javascript:void(0)" onclick="approve(' + row.id + ', 1)"><i class="fa fa-edit"></i>审核通过</a> ');
                        	actions.push('<a class="btn btn-danger btn-xs ' + approveFlag + '" href="javascript:void(0)" onclick="approve(' + row.id + ', -1)"><i class="fa fa-edit"></i>拒绝申请</a> ');
                        }
                        if(row.status == 2){
                        	actions.push('<a class="btn btn-danger btn-xs ' + transferFlag + '" href="javascript:void(0)" onclick="transfer(' + row.id + ', ' + row.yuan + ')"><i class="fa fa-remove"></i>转帐汇款</a>');
                        }
                        //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
		/* 提现审核 */
		function approve(id, status) {
			$.modal.confirm(status==1?'确定要审核通过该提请申请吗?':'确定拒绝该提现申请吗?', function() {
				$.operate.post(prefix + "/approve", { "id": id, "status": status });
		    })
		}
		
		/* 转帐汇款 */
		function transfer(id, yuan) {
			$.modal.confirm('确定该提现并转帐吗?金额[' + yuan + ']', function() {
				$.operate.post(prefix + "/transfer", { "id": id});
		    })
		}
        
    </script>
</body>
</html>